package com.transcargo.rating;

import com.transcargo.db.db;
import com.transcargo.db.dbException;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * Date: 24.04.2011
 * Time: 17:28:59
 */
public class Comment {
    private int Id = 0;
    private int Debt_Id = 0;
    private int author = 0;
    private String date = "";
    private String comment = "";
    public Comment(int id, int debt_id, db dbase) {
        Id = id;
        Debt_Id = debt_id;
        try {
            ArrayList<String[]> list = dbase.execute("SELECT author, date, comment FROM comments WHERE id=" + id + " AND debt_id=" + debt_id);
            if (list != null) {
                Iterator<String[]> iter =list.iterator();
                if (iter.hasNext()) {
                    String[] ctr = iter.next();
                    author = Integer.parseInt(ctr[0]);
                    date = ctr[1];
                    comment = ctr[2];
                }
            }
        } catch (dbException e) {
            System.out.println("Comment exception! Unable to find comment id " + id);
        }
    }
    public int getId() {
        return Id;
    }
    public int getDebtId() {
        return Debt_Id;
    }
    public int getAuthor() {
        return author;
    }
    public String getDate() {
        return date;
    }
    public String getComment() {
        return comment;
    }
}
